import orm

def login():
    tag=0
    name=input('请输入你的用户名：')
    pwd=input('请输入你的密码：')
    sql=f"""select * from user where username='{name}' and password='{pwd}'"""
    data = orm.read_data(sql)
    if data != ():
        tag = 1
    return tag

def register():
    tag = 0
    name = input('请输入要注册的用户名：')
    pwd = input('请输入要注册的密码：')
    sql = f"""
        insert into user values('{name}','{pwd}')
    """
    rows = orm.write_data(sql)
    if rows > 0:
        tag = 1
    return tag


if __name__ == '__main__':
    # 测试一下 assert()
    print(login())
    # 测试一下 register()
    print(register())
